from django.db import models
from django.contrib.auth.models import User
# Create your models here.



class Blog(models.Model):
    owner = models.OneToOneField(User)
    name = models.CharField(max_length=100)
    url_name = models.CharField(max_length=20, unique=True)
    description = models.CharField(max_length=300)

    def __unicode__(self):
        return 'Blog {0}, Owner {1}'.format(self.name, self.owner)

class Entry(models.Model):
    blog = models.ForeignKey('Blog')
    title = models.CharField(max_length=100)
    text = models.CharField(max_length=10000)
    datetime = models.DateTimeField()

    def __unicode__(self):
        return 'Entry {0} in Blog {1}'.format(self.title, self.blog)

class Comment( models.Model ):
    commenter = models.ForeignKey( User )
    entry = models.ForeignKey( 'Entry' )
    title = models.CharField( max_length=100 )
    text = models.TextField()
    datetime = models.DateTimeField();

    def __unicode__( self ):
        return 'Comment {0} in Entry {1}'.format( self.title, self.entry )
